<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目类型：</label>
                                <div class="col-sm-8">
                                    <select name="projectType" class="form-control m-b" th:with="type=${@dict.getType('lh_project_type')}">
                                        <option value="">全部</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </div>
                            </li>
                            <li>
                                <label>设备型号：</label>
                                <div class="col-sm-8">
                                    <select name="machineNo" class="form-control m-b" th:with="machineList=${machineList}">
                                        <option value="">全部</option>
                                        <option th:each="machine : ${machineList}" th:text="${machine.machineNo}" th:value="${machine.machineNo}"></option>
                                    </select>
                                </div>
                            </li>
                            <li>
                                <label>硬件版本：</label>
                                <input type="text" name="hardwareVersion"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="lh:machine:add">
                    <i class="fa fa-plus"></i> 新增设备
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="lh:machine:remove">
                    <i class="fa fa-remove"></i> 批量删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="lh:machine:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <!-- 导入区域 -->
     <script id="importTpl" type="text/template">
         <form enctype="multipart/form-data" class="mt20 mb10">
             <div class="col-xs-offset-1">
                 <input type="file" id="file" name="file"/>
                 <div class="mt10 pt5">
                     &nbsp;	<a onclick="window.open('/lh/machine/importTemplate')" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
                 </div>
                 <font color="red" class="pull-left mt10">
                     提示：仅允许导入“xls”或“xlsx”格式文件！
                 </font>
             </div>
         </form>
     </script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('lh:machine:edit')}]];
        var removeFlag = [[${@permission.hasPermi('lh:machine:remove')}]];
        var machineTypeDatas = [[${@dict.getType('lh_machine_type')}]];
        var isAcceptUpdateDatas = [[${@dict.getType('lh_machine_accept')}]];
        var releaseAreaDatas = [[${@dict.getType('lh_machine_area')}]];
        var statusDatas = [[${@dict.getType('lh_machine_open')}]];
        var prefix = ctx + "lh/machine";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                modalName: "设备",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'machineNo',
                    title: '设备型号'
                },
                {
                    field: 'machineType',
                    title: '设备类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(machineTypeDatas, value);
                    }
                },
                {
                    field: 'sn',
                    title: '设备SN'
                },
                {
                    field: 'hardwareVersion',
                    title: '硬件版本'
                },
                {
                    field: 'initialSoftwareVersion',
                    title: '初始软件版本'
                },
                {
                    field: 'status',
                    title: '软件/设备状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'releaseDate',
                    title: '出厂时间'
                },
                {
                    field: 'releaseArea',
                    title: '设备所在区域',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(releaseAreaDatas, value);
                    }
                },
                {
                    field: 'isAcceptUpdate',
                    title: '是否允许更新',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(isAcceptUpdateDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>
